#!/usr/bin/env python3
"""
简单测试Qwen3-VL API - 使用更短的超时和简单提示词
"""
import requests
import json
import time

def test_simple():
    """简单测试"""
    
    api_url = "http://192.168.200.19:18009/api/generate"
    video_url = "http://192.168.210.72:8000/videos/502be57a-11fa-465a-8708-b993125d399e.mp4"
    
    # 使用更简单的提示词
    request_data = {
        "prompt": "描述视频内容",
        "model": "Qwen3-VL",
        "videos": [video_url],
        "stream": False
    }
    
    headers = {
        "Content-Type": "application/json",
        "Accept": "*/*",
        "Connection": "keep-alive"
    }
    
    print("🚀 简单测试Qwen3-VL...")
    print(f"提示词: {request_data['prompt']}")
    
    try:
        start_time = time.time()
        
        # 使用较短的超时时间先测试
        response = requests.post(
            api_url,
            json=request_data,
            headers=headers,
            timeout=60  # 1分钟超时
        )
        
        end_time = time.time()
        
        print(f"⏱️ 耗时: {end_time - start_time:.2f}秒")
        print(f"📊 状态: {response.status_code}")
        
        if response.status_code == 200:
            print("✅ 成功！")
            try:
                result = response.json()
                print("📄 结果:")
                print(json.dumps(result, ensure_ascii=False, indent=2))
            except:
                print("📄 文本结果:")
                print(response.text)
        else:
            print("❌ 失败")
            print(f"错误: {response.text}")
            
    except requests.exceptions.Timeout:
        print("❌ 超时 - 可能视频太大或模型处理时间过长")
        print("💡 建议:")
        print("   1. 检查视频大小是否过大")
        print("   2. 尝试使用更小的视频文件")
        print("   3. 检查Qwen3-VL服务配置")
    except Exception as e:
        print(f"❌ 错误: {e}")

if __name__ == "__main__":
    test_simple()